package logic

import (
	"context"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetContinuousSignDaysLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetContinuousSignDaysLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetContinuousSignDaysLogic {
	return &GetContinuousSignDaysLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetContinuousSignDaysLogic) GetContinuousSignDays(in *user.GetContinuousSignDaysRequest) (*user.GetContinuousSignDaysResponse, error) {
	// 调用dao层的查询连续签到天数函数
	days, err := dao.GetContinuousSignDays(in.UserId)
	if err != nil {
		return nil, err
	}
	// 返回查询结果
	return &user.GetContinuousSignDaysResponse{
		Days: days,
	}, nil
}
